package wicket;

import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;

public class ListPanel extends Panel{

	private static final long serialVersionUID = 1L;
	private MessageForm messageForm; // Formulaire d'ajout
	private ListView messageListView; // Affichage du livre d'or
	
	public ListPanel(String id) {
		super(id);
		// Ajout du formulaire
		messageForm = new MessageForm("messageForm");
		add(messageForm);
		
		// Ajout des messages
		add(messageListView = new ListView("messages", messageForm.getListMessage()){

			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(ListItem listItem) {
				Message message = (Message)listItem.getModelObject();
	                listItem.add(new MultiLineLabel("text", message.getMessage()));
			}
			
		});
		
	}
	
	public void setMessageListView(ListView messageListView) {
		this.messageListView = messageListView;
	}

	public ListView getMessageListView() {
		return messageListView;
	}

}
